using System;
using System.Collections.Generic;
using System.Data;

using Elev.Core.DAL;

namespace Elev.Core
{
    public class ExamTypesFactory
    {
        public List<ExamType> GetExamTypes()
        {
            ExamTypeInternal e = new ExamTypeInternal();
            DataTable dt = e.GetExamTypes();
            List<ExamType> list = new List<ExamType>();

            if (dt.Rows.Count > 0)
                foreach (DataRow dr in dt.Rows)
                    list.Add(new ExamType(dr));

            return list;
        }

        public ExamType GetExamType(int ID)
        {
            ExamTypeInternal e = new ExamTypeInternal();
            DataTable dt = e.GetExamType(ID);

            if (dt.Rows.Count == 0)
                throw new ArgumentException(string.Format("There is no exam type for the id '{0}'", ID));

            if (dt.Rows.Count > 1)
                throw new ArgumentException(string.Format("There is more than one exam type for the id '{0}'", ID));

            return new ExamType(dt.Rows[0]);
        }
    }
}
